package palf.visualEffects.timing {

import com.greensock.TimelineLite;
import com.greensock.TweenLite;

import palf.visualEffects.utils.PositionData;

public class Step implements Timing {

	private var duration : Number;
	private var count : Number;

	public function Step(duration : Number, count : Number) {
		this.duration = duration;
		this.count = count
	}

	public function apply(data : PositionData) : void {
		var timeline : TimelineLite = new TimelineLite();
		var x_target : Number = data.target.x;
		var y_target : Number = data.target.y;
		var x_quotient : Number = (data.x - x_target) / count;
		var y_quotient : Number = (data.y - y_target) / count;

		for (var i : uint = 0; i < count; i++) {
			x_target += x_quotient;
			y_target += y_quotient;
			timeline.append(TweenLite.to(data.target, duration / count, { x: x_target, y: y_target }), 0);
		}
	}

	public function reset() : void {

	}
}

}
